package com.walk.zworld.mvvm.vm

import androidx.lifecycle.LiveData
import com.base.lib.httpUtils.BaseListResponseBody
import com.base.lib.httpUtils.CollectionArticle
import com.walk.zworld.mvvm.repository.CollectRepository
import com.base.lib.base.event.SingleLiveEvent
import com.base.lib.base.mvvm.viewmodel.BaseRefreshViewModel

class MyCollectActivityViewModel : BaseRefreshViewModel<CollectionArticle>() {

    private val repository = CollectRepository()
    private val collectList = SingleLiveEvent<BaseListResponseBody<CollectionArticle>>()

    fun getCollectList(page: Int): LiveData<BaseListResponseBody<CollectionArticle>> {
        launchUI {
            val res = repository.getCollectList(page)
            collectList.value = res.data!!
            mData.value = res.data.datas
        }
        return collectList
    }

    override fun refreshData(params: Any?) {
        page = 0;
        getCollectList(page);
    }

    override fun loadMore(params: Any?) {
        page ++;
        getCollectList(page);
    }
}